<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Machine
 *
 * @author Quentin
 */
class Machine implements JsonSerializable{
    private $id = -1;
    private $ipAddr = "";
    private $infos = "";
    private $ram = -1;
    private $disk = -1;
    public function __construct($ipAddr, $infos = "", $ram = -1, $disk = -1){
        $this->ipAddr = $ipAddr;
        $this->infos = $infos;
        $this->ram = $ram;
        $this->disk = $disk;
    }
    public function __toString(){
        return "Machine[ip='$this->ipAddr', infos='$this->infos']";
    }
    public function getId(){
        return $this->id;
    }
    public function setId($id){
        $this->id = $id;
    }
    public function getIpAddress(){
        return $this->ipAddr;
    }
    public function setIpAddress($ipAddr){
        $this->ipAddr = $ipAddr;
    }
    public function getInfos(){
       return $this->infos;
    }
    public function setInfos($infos){
        $this->infos = $infos;
    }
    public function getRam(){
       return $this->ram;
    }
    public function setRam($ram){
        $this->ram = $ram;
    }
    public function getDisk(){
       return $this->disk;
    }
    public function setDisk($disk){
        $this->disk = $disk;
    }
    public function jsonSerialize() {
        $json = Array();
        $json["id"] = $this->id;
        $json["ip"] = $this->ipAddr;
        $json["infos"] = $this->infos;
        $json["ram"] = $this->ram;
        $json["disk"] = $this->disk;
        return $json;
    }
    public function xmlSerialize($domtree){
        $xmlRoot = $domtree->createElement("machine");
        $ip = $domtree->createElement("ip", $this->ipAddr);
        $xmlRoot->appendChild($ip);
        $id = $domtree->createElement("id", $this->id);
        $xmlRoot->appendChild($id);
        $infos = $domtree->createElement("infos", $this->infos);
        $xmlRoot->appendChild($infos);
        $ram = $domtree->createElement("ram", $this->ram);
        $xmlRoot->appendChild($ram);
        $disk = $domtree->createElement("disk", $this->disk);
        $xmlRoot->appendChild($disk);
        return $xmlRoot;
    }
}

?>
